package com.mhc.suzuki.service.scheduled;

import com.mhc.suzuki.service.CarModelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutionException;


/**
 * 从数据库中加载车型到内存List中
 *
 * @author kanon
 * @create 2017-09-08 11:52
 **/
@Slf4j
@Component
public class CarModelCacheTask {

    @Autowired
    private CarModelService carModelService;

    /**
     * 半小时重新加载车型到内存中
     */
    @Scheduled(fixedRate = 1800000)
    public void reflushCarModelList() throws ExecutionException {
        log.info("重建车型缓存运行开始");
        carModelService.getCarModelList("");
        log.info("重建车型缓存运行结束");
    }

}
